<!DOCTYPE html>
<html dir="ltr" lang="cn">
<head>
    <meta charset="UTF-8" />
    <title>众创织梦配送清单</title>
    <script type="text/javascript" src="__PUBLIC__/plugins/jQuery/jQuery-2.1.4.min.js"></script>
	<script src="/Public/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <link href="__PUBLIC__/bootstrap/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
    <style media="print" type="text/css">.noprint{display:none}</style>
</head>
<body>
<div class="container">
<script type="text/javascript"> 
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件  
return this.each(function(){ 
var that; 
$('tr', this).each(function(row) { 
$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 
if (that!=null && $(this).html() == $(that).html()) { 
rowspan = $(that).attr("rowSpan"); 
if (rowspan == undefined) { 
$(that).attr("rowSpan",1); 
rowspan = $(that).attr("rowSpan"); } 
rowspan = Number(rowspan)+1; 
$(that).attr("rowSpan",rowspan); 
$(this).hide(); 
} else { 
that = this; 
} 
}); 
}); 
}); 
}

$(document).ready(function(){
	$(".g_list").rowspan(0);
	$(".g_list").rowspan(1);
	$(".g_list").rowspan(2);
	$(".g_list").rowspan(7);
}); 

function dayin_num(){
	$.post("/index.php/Admin/Order/order_print",
	  {
		action:"yes",
	    order_id:"{$orderList.order_id}"
	  },
	  function(data,status){ console.log(data);});
}
</script>
<style type="text/css">
	.g_list .mytd{height:25px;}
	.title_pic{float: left;}
	.text-center{font-size: 14px;}
	.table{border-collapse: collapse;border-spacing: 0;}
	.table td{border: 1px solid;border-collapse: collapse;border-spacing: 0;height:45px;line-height:25px;text-align: center;}
</style>
<div id="divMMHeight" style="height:1mm;display:none;"></div>
<input style="background: #007BB6;color: #fff;width:80px;font-size:18px;line-height: 35px;border-radius: 10px;border:none;position: absolute;margin-left: 25%;" type="button" onclick="jisuan();dayin_num();window.print();" value="打印">
    <div style="page-break-after: always;">
		<script type="text/javascript">
		function jisuan(){
		  var mmtoPx=$("#divMMHeight").height();
		  $("body #mytable").each(function(){
			  var mytable_h=$(this).height()/mmtoPx-3;
				$(this).css('margin-bottom',bt(mytable_h)+'mm');
			  console.log(mytable_h);
		  });
		  $("body #mytable:last").css('margin-bottom','10mm');
		  }
		 // alert(getnum(7/2));
		  function bt(myh){
			  var pd=myh/270; //占用页数
			  return getnum(pd)*270+270;
		  }
		  function getnum(num)
		  {
		  var result = num.toString().replace(/\d+\.(\d*)/,"$1")
		  return parseFloat('0.'+result);
		  }
		    </script> 
				
             <form method="get" target="_blank" id="form-order">
                <div class="table-responsive">
					<?php
					foreach($orderList as $v){
					?>
					<h1 align="center">众创织梦配送清单</h1>
                    <table class="table table-bordered" style="width: 210mm;margin: auto;" id="mytable">
                                <tbody>
                                    <tr>
										<td class="text-center" style="background:#EAF8FF;">客店名：{$v.company}</td>
                                        <td class="text-center" style="background:#EAF8FF;">客户名：{$v.nickname}<if condition="$v['is_cod'] eq '1'"><span style="color: red">(货到付款)</span></if></td>
                                        <td class="text-center" style="background:#EAF8FF;">标识：{$v.biaoshi}</td>
                                        
                                        <td class="text-center" style="background:#EAF8FF;">电话：{$v.mobile}</td>
                                        <td class="text-center" style="background:#EAF8FF;">地址：{$v.company_address}</td>
                                    </tr>
									
<tr>
<td class="text-center" colspan="8" style="padding:0;">
	

<table class="table table-bordered g_list" style="width:100%;">
<tr>
		<td style="width: 120px;" class="mytd">商家</td>
		<td style="width: 120px;" class="mytd">商家订单号</td>
		<td style="width: 80px;" class="mytd">包装件数</td>
		<td style="width: 220px;" class="mytd">产品名</td>
		<td style="width: 90px;" class="mytd">数量</td> 
		<td style="width: 90px;" class="mytd">单价</td>
		<td style="width: 90px;" class="mytd">小计</td>
		<td style="width: 100px;" class="mytd">订单金额</td>
</tr>
<?php
	$zongje=$zongjian=0;
	?>
<volist name="v['order_list']" id="lists">
	<?php
	$zongje+=$lists['order_amount'];
	$zongjian+=$lists['jian_count'];
	$points_count=0;
	$admin_note=$lists['admin_note'];
	$discount=$lists['discount'];
	?>
	<volist name="lists.g_list" id="listss">
		<?php
		$xiaoji=sanwei(($listss['member_goods_price']*$listss['goods_num']));
		$points_count+=$listss['points']*$listss['member_goods_price']*$listss['goods_num']/100;
		?>
	<tr>
		<td class="mytd" style="text-align: left;"><b>{$store_list[$lists[store_id]]}</b>
		<br/>
		<span style="color:#948e8e;">
		入库：{$lists.ruku_time|date='Y-m-d H:i',###}
		</span>
		</td> 
		<td class="mytd">**{:substr($lists['order_sn'],-6)}
		</td>
		<td class="mytd"><span style="display: none;">{$lists.order_id}</span>{$lists.jian_count}件</td>
		<td style="text-align:left;">
			<div class="title">{$listss.goods_name}</div>
			<div class="title" style="color:#8e8a8a;">{$listss.spec_key_name}</div>
			</td>
		<td class="mytd">{$listss.goods_num}</td> 
		<td class="mytd">￥{$listss.member_goods_price}</td> 
		<td class="mytd">￥{:sanwei($xiaoji)}</td>
		<td class="mytd" style="color:red;font-size:13px">￥{$lists.order_amount}<span style="display:none;">{$lists['order_sn']}</span></td>
	</tr>
</volist>

</volist>
<tr>
	<td class="mytd" colspan="2" style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">总件数：</td>
	<td class="mytd" style="font-weight: bold;font-size:16px">{$zongjian} 件</td>
	<td class="mytd" colspan="3" style="font-weight: bold;font-size:13px;text-align: left;">
		<b>改单：</b>
						<if condition="$admin_note eq ''">
								<span style="color:#999;">未改单</span>
						<else/>
								<span style="color:red;">改价：<b>￥{$discount}</b>，{$admin_note|htmlspecialchars_decode}</span>
						</if>
	</td>
	<td class="mytd" style="font-weight: bold;font-size:16px;text-align: right;height: 45px;">应收额：</td>
	<td class="mytd" style="font-weight: bold;font-size:16px;color: red;">￥{:sanwei($zongje)}</td>
</tr>

</table>
	</td>
</tr>
</tbody>
</table>
<?php
}
?>
</div>
</form>
    </div>
</div>
</body>
</html>